#ifndef __MENU_H
#define __MENU_H

#define KEY_INITIALIZE  0
#define KEY_UPWARD      1
#define KEY_DOWNWARD    2
#define KEY_FORWARD     3
#define KEY_BACKWARD    4
#define KEY_ACTION      5


#define MAX_NESTING_LEVEL 5

class Menu
{
  public:
	typedef void (*tMenuPrint)( const char* line1, const char* line2);
	//typedef void (*tMenuPrint)();
	typedef void (*tMenuProcessKey)( const char key);
	typedef void (*tMenuAction)();
	typedef struct tMenuItem {
//	    doMenu func;
	    const char isLastItem;
	    const char* line1;
	    const char* line2;
	    tMenuPrint print;
	    tMenuProcessKey processKey;
	    tMenuAction action;
	    tMenuItem (*submenu)[];
	} MenuItem;

  private:
	static tMenuItem mainMenu[];
	tMenuItem (*currentMenu)[];
  	int idxCurrentMenu[MAX_NESTING_LEVEL];
  	int top;

  public:
  	Menu();
	void print();
	void reset();
	void moveForward();
	void moveBackward();
	void moveUp();
	void moveDown();
	void doAction();
	void processKey( char key);
	void updateEventually();
};

extern Menu menu;

#endif
